package com.example.studyplanning.servicesImpl;

import com.example.studyplanning.entity.User;
import com.example.studyplanning.mapper.UserMapper;
import com.example.studyplanning.services.UserServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import java.util.List;

@Service
public class UserServicesImpl implements UserServices {
    @Autowired
    private UserMapper userMapper;

    @Override
    public List<User> getUser(Integer userID) {
        return userMapper.getUser(userID);
    }

    @Override
    public Integer UpdateUserDislike(Integer userID) {
        return userMapper.UpdateUserDislike(userID);
    }

    @Override
    public Integer UpdateDislike(Integer userID) {
        return userMapper.UpdateDislike(userID);
    }

    @Override
    public List<User> FindAllUser() {
        return userMapper.FindAllUser();
    }

    @Override
    public PageInfo<User> FindUserByName(String userName, Integer userID,Integer num) {
        PageHelper.startPage(num,8);
        List<User> lists=userMapper.FindUserByName(userName,userID);
        PageInfo<User> pageInfo = new PageInfo<>(lists);
        return pageInfo;
    }

    @Override
    public PageInfo<User> findUserByName(String userName,Integer num) {
       PageHelper.startPage(num,8);
        List<User> lists=userMapper.findUserByName(userName);
        PageInfo<User> pageInfo = new PageInfo<>(lists);
        return pageInfo;
    }

    @Override
    public Integer DelByID(Integer userID) {
        return userMapper.DelByID(userID);
    }

    @Override
    public Integer UpdateUserType(Integer userID) {
        return userMapper.UpdateUserType(userID);
    }

    @Override
    public Integer updateUserType(Integer userID) {
        return userMapper.updateUserType(userID);
    }
    @Override
    public List<User> FindUser() {
        return userMapper.FindUser();
    }

    @Override
    public List<User> findAlluser() {
        List<User>list=userMapper.findAlluser();
        return list;

    }

    @Override
    public List<User> findAllActiveuser() {
        List<User>list=userMapper.findAllActiveuser();
        return list;
    }

}
